package com.zztpc.ljl.myapplication;

import android.content.Context;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;

import java.util.ArrayList;


public class FirstFragment extends Fragment {




    public FirstFragment() {
        // Required empty public constructor
    }


    // TODO: Rename and change types and number of parameters
    public static FirstFragment newInstance(String param1, String param2) {
        FirstFragment fragment = new FirstFragment();
        Bundle args = new Bundle();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View inflate = inflater.inflate(R.layout.fragment_first, container, false);
        LineChart lineChart=inflate.findViewById(R.id.line_Chart);
        //List<Entity> list = new ArrayList<>();
        ArrayList<Entry> list1=new ArrayList<>();
        list1.add(new Entry(1,3));
        list1.add(new Entry(2,8));
        list1.add(new Entry(3,6));
        list1.add(new Entry(4,4));
        list1.add(new Entry(5,3));
        ArrayList<Entry> list2=new ArrayList<>();
        list2.add(new Entry(2,6));
        list2.add(new Entry(4,5));
        list2.add(new Entry(7,2));
        list2.add(new Entry(8,6));
        list2.add(new Entry(3,6));
        LineDataSet lineDataSet=new LineDataSet(list1,null);
        lineDataSet.setColor(Color.BLACK);
        LineDataSet lineDataSet1=new LineDataSet(list2,null);
        lineDataSet1.setColor(Color.RED);
        ArrayList<ILineDataSet> list_linData=new ArrayList<>();
        list_linData.add(lineDataSet);
        list_linData.add(lineDataSet1);
        LineData lineData=new LineData(list_linData);

        lineChart.setData(lineData);
        XAxis xAxis=lineChart.getXAxis();
        return inflate;
    }

    // TODO: Rename method, update argument and hook method into UI event
    public void onButtonPressed(Uri uri) {

    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

    }

    @Override
    public void onDetach() {
        super.onDetach();

    }



}
